package dhm.com.dhmshop.adapter.mine;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import dhm.com.dhmshop.R;
import dhm.com.dhmshop.base.netWork.Constant;
import dhm.com.dhmshop.entity.FootBean;
import dhm.com.dhmshop.entity.GetCashListBean;
import dhm.com.dhmshop.view.mine.myshop.CashdetailActivity;

/**
 * Created by admin
 * 2019/4/29
 * 所有订单适配器
 */
public class CashAdapter extends RecyclerView.Adapter<CashAdapter.ViewHolder> {

    private List<GetCashListBean.DataBean> shopList;
    private Context context;


    public CashAdapter(Context context) {
        this.shopList = new ArrayList<>();
        this.context = context;
    }


    public void setShopList(List<GetCashListBean.DataBean> shopList) {
        this.shopList = shopList;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        ViewHolder viewHolder;
        View view= LayoutInflater.from(context).inflate(R.layout.item_cash, viewGroup,false);
        viewHolder=new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder viewHolder, final int i) {
        if (shopList.get(i).getAccount_type()==1){
            viewHolder.name.setText("提现 - 到支付宝"+shopList.get(i).getAccount().substring(0,2)+"****"+shopList.get(i).getAccount().substring(6,10));

        }
        viewHolder.money.setText("￥"+shopList.get(i).getMoney()+"");

        viewHolder.time.setText(shopList.get(i).getAdd_time());

        viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(context, CashdetailActivity.class);
                intent.putExtra("shop_id",shopList.get(i).getShop_id()+"");
                intent.putExtra("cash_id",shopList.get(i).getCash_id()+"");
                context.startActivity(intent);
            }
        });


    }

    private boolean isdel=false;

    public boolean isIsdel() {
        return isdel;
    }

    public void setIsdel(boolean isdel) {
        this.isdel = isdel;
        notifyDataSetChanged();
    }


    @Override
    public int getItemCount() {
        return shopList.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder {

        public TextView name;
        public TextView money;
        public TextView time;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            name=itemView.findViewById(R.id.name);
            money=itemView.findViewById(R.id.money);
            time=itemView.findViewById(R.id.time);
        }
    }

    private OnClick ondelClick;
    public void setdeleteClick(OnClick onClick) {
        this.ondelClick = onClick;
    }
    public interface OnClick{
        void item(int posttion);
    }


    private OneditClick oneditClick;
    public void seteditClick(OneditClick onClick) {
        this.oneditClick = onClick;
    }
    public interface OneditClick{
        void item(int posttion);
    }

    private OnIntentClick onIntentClick;
    public void setaddClick(OnIntentClick onClick) {
        this.onIntentClick = onClick;
    }
    public interface OnIntentClick{
        void item(int posttion);
    }



}

